<template>
	<div>
		<header class="navigation">
			<div @click="retreat"><img src="../assets/rightbut.png"></div>
			<div>我的红包劵</div>
			<div></div>
		</header>
		
		<div class="couponlist">
			
			<div class="couponcontent" v-for='item in coupon'>
				<div class="couponcontent_r">
					<div>￥{{item.amount}}</div>
					<div>{{item.name}}元可用(仅限友惠家商品，特价商品除外)</div>
					<div>使用期限：{{item.startTime}}至{{item.endTime}}</div>
				</div>
				<div class="couponcontent_l" v-if='item.state == 0 '>立即使用</div>
				<div class="couponcontent_l" v-if='item.state == 1 '>已使用</div>
				<div class="couponcontent_ll" v-if='item.state == 2 '>已过期</div>
			</div>
			
		</div>
		
	</div>
</template>

<script>
	import { BaseUrl } from '../Baseurl/common.js';
	import { Toast } from 'mint-ui';
	export default{
		data(){
			return{
				token:'',
				coupon:[],
			}
		},
		created(){
			this.token = localStorage.getItem('token');
			//我的红包劵
			var url = BaseUrl + 'users/mycoupon?appId=wap' + '&token=' + this.token;
			this.$http.get(url).then(res=>{
//				console.log(res.data.data);
				if(res.data.code == '10000'){
					this.coupon = res.data.data;
				}
			}).catch(error=>{
				Toast({
					message: "网络异常",
					position: 'middle',
					duration: 3000
					})
				})
		},
		methods:{
			//导航退后
			retreat:function(){
				window.history.go(-1);
			},
		}
	}
</script>

<style scoped="scoped">
	.navigation{
		height: 1rem;
		background: #fff;
		display: flex;
		border-bottom: 1px solid #dcd2d1;
		justify-content: space-between;
		align-items: center;
		padding: 0 0.24rem;
	}
	
	.navigation img{
		width: 0.2rem;
		height: 0.36rem;
		display: block;
	}
	.couponlist{
		padding: 0 0.25rem;
	}
	.couponcontent{
		margin-top: 0.2rem;
		display: flex;
	}
	.couponcontent_r{
		width: 70%;
		border: 1px solid #ff2040;
		border-radius:0.1rem;
		padding: 0.1rem;
	}
	.couponcontent_r div:nth-child(1){
		color: #ff2040;
		font-size: 0.4rem;
	}
	.couponcontent_r div:nth-child(2){
		color: #cccccc;
		font-size: 0.1rem!important;
	}
	.couponcontent_r div:nth-child(3){
		color: #cccccc;
		font-size: 0.1rem!important;
	}
	.couponcontent_l{
		width: 30%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: url(../assets/coupon.png);
		background-size: 100% 100%;
		text-align: center;
		color: #fff;
		font-size: 0.3rem;
	}
	.couponcontent_ll{
		width: 30%;
		line-height: 1.97rem;
		background: url(../assets/coupons.png);
		background-size: 100% 100%;
		text-align: center;
		color: #fff;
		font-size: 0.3rem;
	}
</style>